//
//  tklCAGradientLayer.m
//  boboBoom
//
//  Created by wxt on 2021/3/4.
//  Copyright © 2021 emiyajin. All rights reserved.
//

#import "tklCAGradientLayer.h"

@implementation tklCAGradientLayer

+(instancetype)layerWithFrame:(CGRect)frame{
    
    tklCAGradientLayer *glr = [tklCAGradientLayer layer];
    glr.frame = frame;
    glr.startPoint = CGPointMake(0, 0);
    glr.endPoint = CGPointMake(1, 1);
    glr.colors = @[(__bridge id)[UIColor colorWithRed:229/255.0 green:28/255.0 blue:35/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:255/255.0 green:77/255.0 blue:29/255.0 alpha:1.0].CGColor];
    glr.locations = @[@(0.0),@(1.0f)];
    
    return glr;
    
}

+(instancetype)layerWithFrame:(CGRect)frame
                         startPointx:(CGFloat )spointx
                   startPointy:(CGFloat)spointy
                         endPointx:(CGFloat)epointx
                     endPointy:(CGFloat)epointy
                  startColorR:(CGFloat )startColorR
                  startColorG:(CGFloat)startColorG
                  startColorB:(CGFloat)startColorB
              endColorR:(CGFloat)endColorR
                    endColorG:(CGFloat )endColorG
                    endColorB:(CGFloat)endColorB{
    
    tklCAGradientLayer *glr = [tklCAGradientLayer layer];
    glr.frame = frame;
    glr.startPoint = CGPointMake(spointx, spointy);
    glr.endPoint = CGPointMake(epointx, epointy);
    glr.colors = @[(__bridge id)[UIColor colorWithRed:startColorR/255.0 green:startColorG/255.0 blue:startColorB/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:endColorR/255.0 green:endColorG/255.0 blue:endColorB/255.0 alpha:1.0].CGColor];
    glr.locations = @[@(0.0),@(1.0f)];
    
    return glr;
    
    
    
}

+(instancetype)layerWithFrame:(CGRect)frame
                  startColorR:(CGFloat )startColorR
                  startColorG:(CGFloat)startColorG
                  startColorB:(CGFloat)startColorB
              endColorR:(CGFloat)endColorR
                    endColorG:(CGFloat )endColorG
                    endColorB:(CGFloat)endColorB{
    
    tklCAGradientLayer *glr = [tklCAGradientLayer layer];
    glr.frame = frame;
    glr.startPoint = CGPointMake(0, 0);
    glr.endPoint = CGPointMake(0, 0);
    glr.colors = @[(__bridge id)[UIColor colorWithRed:startColorR/255.0 green:startColorG/255.0 blue:startColorB/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:endColorR/255.0 green:endColorG/255.0 blue:endColorB/255.0 alpha:1.0].CGColor];
    glr.locations = @[@(0.0),@(1.0f)];
    
    return glr;
    
}

@end
